﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CMS.BLL;
public partial class Controls_FAQ_ctrFAQMenu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitData();
        BindData();
    }
    private void InitData()
    {
        int nCurrentLanguage = Support.GetCurrentLanguage();
        lnkFAQ.Text = MultipleLanguage.FAQ_MENU[nCurrentLanguage-1];
        lnkFAQ.NavigateUrl = Config.ROOT + Pages.FrontEnds.FAQ_CATEGORY;
    }
    private void BindData()
    {
        DataTable dtbFAQs = new DataTable();
        FAQCategory objFAQCat = new FAQCategory();
        dtbFAQs = objFAQCat.Search();
        rptFAQ.DataSource = dtbFAQs;
        rptFAQ.DataBind();
    }
    protected void rptFAQ_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if((e.Item.ItemType != ListItemType.Header)&&(e.Item.ItemType!=ListItemType.Footer))
        {
            HyperLink lnkFAQTitle = (HyperLink)e.Item.FindControl("lnkFAQTitle");
            int nID = ConvertData.ConvertToInt(DataBinder.Eval(e.Item.DataItem, "FAQCategoryID"));
            int nCurrentLanguage = Support.GetCurrentLanguage();
            switch (nCurrentLanguage)
            {
                case 1:
                    lnkFAQTitle.Text = ConvertData.ConvertToString(DataBinder.Eval(e.Item.DataItem, "Description1"));
                    break;
                case 2: 
                    lnkFAQTitle.Text = ConvertData.ConvertToString(DataBinder.Eval(e.Item.DataItem, "Description2"));
                    break;
                case 3:
                    lnkFAQTitle.Text = ConvertData.ConvertToString(DataBinder.Eval(e.Item.DataItem, "Description3"));
                    break;

            }
            lnkFAQTitle.NavigateUrl = Config.ROOT + Pages.FrontEnds.FAQ_CATEGORY + "?" + Config.FAQ_CAT + "=" + nID;
        }
    }
}